package com.xbongbong.parent.interfaces;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.dto.FormDataUpdateBatchDTO;
import com.xbongbong.paas.pojo.vo.FormDataUpdateBatchVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.parent.pojo.BatchEditValidateReturnPoJo;

import java.util.List;

/**
 * 批量编辑
 * @author 吴峰
 * @date 2022/11/14 10:30
 */
public interface BusinessBatchEditService<F, D> {

    /**
     * 通用方法层
     * @param formDataUpdateBatchDTO
     * @return
     * @throws XbbException
     */
    FormDataUpdateBatchVO updateBatch(FormDataUpdateBatchDTO formDataUpdateBatchDTO) throws XbbException;
    /**
     *
     * @return
     */
    List<Integer> businessType();

    /**
     * 权限校验
     * @param formDataUpdateBatchDTO
     * @throws XbbException
     */
    void verifyEditPermission(FormDataUpdateBatchDTO formDataUpdateBatchDTO) throws XbbException;

    /**
     * 校验数据编辑权限(团队权限&共享权限)
     *
     * @param formDataUpdateBatchDTO
     * @param formEntity
     * @param formDataList
     */
    void checkDataEditPermission(FormDataUpdateBatchDTO formDataUpdateBatchDTO, F formEntity, List<D> formDataList) throws XbbException;

    /**
     * 获取数据
     * @param formDataUpdateBatchDTO
     * @return
     * @throws XbbException
     */
    List<D> dataListAndSubDataList(FormDataUpdateBatchDTO formDataUpdateBatchDTO) throws XbbException;

    /**
     * 获取字段解释
     * @param formDataUpdateBatchDTO
     * @param dataList
     * @return
     * @throws XbbException
     */
    List<FieldAttrEntity> getExplainList(FormDataUpdateBatchDTO formDataUpdateBatchDTO, List<D> dataList) throws XbbException;

    /**
     * 获取表单实体
     * @param formDataUpdateBatchDTO
     * @param dataList
     * @return
     * @throws XbbException
     */
    F getFormEntity(FormDataUpdateBatchDTO formDataUpdateBatchDTO, List<D> dataList) throws XbbException;

    /**
     * 复杂校验
     * 包括防重复校验以及审批字段校验，以及字段权限校验
     * @param formDataUpdateBatchDTO
     * @param explainList
     * @param dataList
     * @return
     * @throws XbbException
     */
    BatchEditValidateReturnPoJo validateData(FormDataUpdateBatchDTO formDataUpdateBatchDTO, List<FieldAttrEntity> explainList, List<D> dataList) throws XbbException;

    /**
     * 批量编辑主方法
     * @param formDataUpdateBatchDTO
     * @param batchEditValidateReturnPoJo
     * @param dataList
     * @param formEntity
     * @param list
     * @return
     * @throws XbbException
     */
    FormDataUpdateBatchVO batchEditAttr(FormDataUpdateBatchDTO formDataUpdateBatchDTO, BatchEditValidateReturnPoJo batchEditValidateReturnPoJo, List<D> dataList, F formEntity, List<FieldAttrEntity> list) throws XbbException;

    /**
     * 触发工作流或者业务规则
     * @param formDataUpdateBatchDTO
     * @param formDataList
     * @param formEntity
     * @throws XbbException
     */
    void after(FormDataUpdateBatchDTO formDataUpdateBatchDTO, List<D> formDataList, F formEntity) throws XbbException;
}
